

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <meta name="layout" content="main" />
        <title>Create Listing</title>         
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLinkTo(dir:'')}">Home</a></span>
            <span class="menuButton"><g:link class="list" action="list">Listing List</g:link></span>
        </div>
        <div class="body">
            <h1>Create Listing</h1>
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <g:hasErrors bean="${listing}">
            <div class="errors">
                <g:renderErrors bean="${listing}" as="list" />
            </div>
            </g:hasErrors>
            <g:form action="save" method="post" >
                <div class="dialog">
                    <table>
                        <tbody>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="listingName">Listing Name:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'listingName','errors')}">
                                    <input type="text" id="listingName" name="listingName" value="${fieldValue(bean:listing,field:'listingName')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="address1">Address1:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'address1','errors')}">
                                    <input type="text" id="address1" name="address1" value="${fieldValue(bean:listing,field:'address1')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="address2">Address2:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'address2','errors')}">
                                    <input type="text" id="address2" name="address2" value="${fieldValue(bean:listing,field:'address2')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="extNumber">Ext Number:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'extNumber','errors')}">
                                    <input type="text" id="extNumber" name="extNumber" value="${fieldValue(bean:listing,field:'extNumber')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="intNumber">Int Number:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'intNumber','errors')}">
                                    <input type="text" id="intNumber" name="intNumber" value="${fieldValue(bean:listing,field:'intNumber')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="city">City:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'city','errors')}">
                                    <input type="text" id="city" name="city" value="${fieldValue(bean:listing,field:'city')}"/>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="country">Country:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'country','errors')}">
                                    <g:select id="country" name="country" from="${listing.constraints.country.inList}" value="${listing.country}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="state">State:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'state','errors')}">
                                    <g:select id="state" name="state" from="${listing.constraints.state.inList}" value="${listing.state}" ></g:select>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="latitude">Latitude:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'latitude','errors')}">
                                    <input type="text" id="latitude" name="latitude" value="${fieldValue(bean:listing,field:'latitude')}" />
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="longitude">Longitude:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'longitude','errors')}">
                                    <input type="text" id="longitude" name="longitude" value="${fieldValue(bean:listing,field:'longitude')}" />
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="createdOn">Created On:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'createdOn','errors')}">
                                    <g:datePicker name="createdOn" value="${listing?.createdOn}" ></g:datePicker>
                                </td>
                            </tr> 
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="pictures">Pictures:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean:listing,field:'pictures','errors')}">
                                    
<ul>
<g:each var="p" in="${listing?.pictures?}">
    <li><g:link controller="picture" action="show" id="${p.id}">${p?.encodeAsHTML()}</g:link></li>
</g:each>
</ul>
<g:link controller="picture" params="['listing.id':listing?.id]" action="create">Add Picture</g:link>

                                </td>
                            </tr> 
                        
                        </tbody>
                    </table>
                </div>
                <div class="buttons">
                    <span class="button"><input class="save" type="submit" value="Create" /></span>
                </div>
            </g:form>
        </div>
    </body>
</html>
